package gui;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JOptionPane;
/**
 * Do not use this one use
 * GuiController.getQuitButton() instead.
 * @author Danny
 *
 */
@SuppressWarnings("serial")
public class QuitButton extends JButton {
	private JButton myButton;
	private String[] myOptions = {"Quit & Save", 
			"Quit Without Saving", "Cancel"};
	public QuitButton() {
		myButton = new JButton( 
		new AbstractAction("Quit") {
			@Override
			public void actionPerformed(ActionEvent e) {
				int selection = 0;
					
					JOptionPane.showOptionDialog(null, 
							"Quit Smart Peer Review", 
							"Quit", 
							JOptionPane.OK_CANCEL_OPTION, 
							JOptionPane.QUESTION_MESSAGE, 
							null, 
							myOptions, 
							0);
					
				switch (selection) {
				case 0:
					// save conference
					System.exit(selection);
					break;
				case 1:
					System.exit(selection);
					break;
				case 2:
					// do nothing
					break;
				}
			}
		});
	}
	
	public JButton getButton() {
		return myButton;
	}
}
	
